package com.zhongxi.guoyuan.utils;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

/**
 * Created by Administrator on 2017/4/5.
 */

public class ImageUtils {

    public static void setHeight(Activity context, float rate, View view){
        int width = context.getWindowManager().getDefaultDisplay().getWidth();  //屏幕宽度
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, (int)(width*rate));
        view.setLayoutParams(lp);
    }

    public static void setRlHeight(Activity context, float rate, View view){
        int width = context.getWindowManager().getDefaultDisplay().getWidth();  //屏幕宽度
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(width, (int)(width*rate));
        view.setLayoutParams(lp);
    }

    /**
     * 获取屏幕高度(px)
     */
    public static int getScreenHeight(Context context) {
        return context.getResources().getDisplayMetrics().heightPixels;
    }
    /**
     * 获取屏幕宽度(px)
     */
    public static int getScreenWidth(Context context) {
        return context.getResources().getDisplayMetrics().widthPixels;
    }
    public static void setPopHeight(Activity context, float rate, View view){
        int width = context.getWindowManager().getDefaultDisplay().getHeight();  //屏幕宽度
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, (int)(width*rate));
        view.setLayoutParams(lp);
    }
}
